/* eslint-disable no-nested-ternary */
/* eslint-disable consistent-return */
/* eslint-disable array-callback-return */
import React from 'react';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import {
  Card,
  Button,
  Spin,
  Select,
  message,
  Steps,
  Divider,
  Row,
  Col,
  InputNumber,
  Table,
  DatePicker,
  Switch,
  Cascader,
  Radio,
} from 'antd';
import { connect } from 'dva';
import router from 'umi/router';
import moment from 'moment';
import queryString from 'query-string';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import DescriptionList from '@/components/DescriptionList';
import { matchDict } from '@/utils/utils';
import styles from '@/utils/utils.less';
import HOCSelect from '@/components/AntDesign/Select';
import DictCode from '../../components/DictCode';

const FormItem = Form.Item;
const { Option } = Select;
const { Step } = Steps;
const { Description } = DescriptionList;
const { MonthPicker } = DatePicker;

@connect(({ adjusttask, loading, publicdata }) => ({
  loading: loading.models.adjusttask,
  adjustInfo: adjusttask,
  dictCode: publicdata.dictCode,
}))
@Form.create()
class BasicForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      secAccoName: '',
      adjId: null,
    };
  }

  componentDidMount() {
    const { dispatch, location } = this.props;
    const query = queryString.parse(location.search);
    // 获取字典
    dispatch({
      type: 'publicdata/fetchDictCode',
      payload: ['BIZ_INS_TYPE', 'BIZ_ACCU_TYPE', 'PAY_FEES_WAY', 'YES_NO_FLAG'],
    }).then(() => {
      // 获取详情信息
      dispatch({
        type: 'adjusttask/fetchAdjInsDetail',
        payload: { sendId: query.sendId, adjId: query.adjId },
      });
      this.setState({ adjId: query.adjId || null });
    });
  }

  componentWillUnmount() {
    const { dispatch } = this.props;
    const resetAdjustInfo = {
      updateBaseInfo: {}, // 基本信息
      updateInsIde: null, // 缴费人员类别
      updateInsLocPkgList: null, // 社保组合
      updateInsPdDecWage: null, // 社保申报工资
      insIdeFlag: false, // 是否修改缴费人员类别
      insIdeList: [], // 缴费人员类别列表
      insWageFlag: false, // 是否修改社保申报工资
      insSetFlag: 1, // 五险合不合一
      isAssSetFlag: '', // 社保工资分项:1是2否
      insLocFlag: false, // 是否修改社保组合
      insSerConfigFlag: '2', // 社保组合是否使用服务配置
      serConfigList: [], // 服务配置列表
      insPayWayList: [], // 社保缴费方式
      accountList: [], // 缴费账户列表
      insGroupList: [], // 社保组合列表
      isHasSerAcco: false, // 有无工伤险种,
      secAccoList: [], // 工伤二级户列表
      insGroupData: [], // 社保组合数据
      insList: [], // 险种集合
      payWay: null, // 缴费方式：1单立户  2大库
      isHasSingle: false, // 有无单立户
      isHasbigStore: false, // 有无大库
      beginDate: undefined,
      isSupplyRun: false, // 是否是供应商执行
    };
    dispatch({
      type: 'adjusttask/updateModelData',
      payload: { ...resetAdjustInfo },
    });
  }

  // switch按钮开关控制
  changeSWitch = (checked, id) => {
    const {
      dispatch,
      adjustInfo: { updateBaseInfo, updateInsLocPkgListOld, updateInsPdDecWage },
    } = this.props;
    dispatch({
      type: 'adjusttask/updateModelData',
      payload: { [id]: checked },
    });
    if (checked) {
      // 打开修改
      if (id === 'insIdeFlag') {
        // 缴费人员列表
        dispatch({
          type: 'adjusttask/fetchInsIdeList',
          payload: { areaId: updateBaseInfo.cityId },
        });
      } else if (id === 'insWageFlag') {
        // 分项险种设置为true，默认值为否,否则为1  (社保申报工资)
        if (updateInsPdDecWage && updateInsPdDecWage.assSetFlag) {
          // 为true
          dispatch({
            type: 'adjusttask/updateModelData',
            payload: { isAssSetFlag: '2' },
          });
        } else {
          dispatch({
            type: 'adjusttask/updateModelData',
            payload: { isAssSetFlag: '1' },
          });
        }
      }
    } else if (!checked && id === 'insWageFlag') {
      // 分项险种设置为true，默认值为否,否则为1
      if (updateInsPdDecWage && updateInsPdDecWage.assSetFlag) {
        // 为true
        dispatch({
          type: 'adjusttask/updateModelData',
          payload: { isAssSetFlag: '2' },
        });
      } else {
        dispatch({
          type: 'adjusttask/updateModelData',
          payload: { isAssSetFlag: '1' },
        });
      }
    } else if (!checked && id === 'insLocFlag') {
      dispatch({
        type: 'adjusttask/updateModelData',
        payload: { insSerConfigFlag: '2', payWay: null },
      });
      dispatch({
        type: 'adjusttask/updateModelData',
        payload: {
          insGroupData: JSON.parse(JSON.stringify(updateInsLocPkgListOld)) || [],
        },
      });
    }
  };

  // 单选按钮控制：打开产品分项设置,服务配置等
  changeRadio = (e, id) => {
    e.preventDefault();
    const { dispatch, adjustInfo } = this.props;
    dispatch({
      type: 'adjusttask/updateModelData',
      payload: {
        [id]: e.target.value,
      },
    });
    if (id === 'insSerConfigFlag') {
      dispatch({
        type: 'adjusttask/updateModelData',
        payload: {
          [id]: e.target.value,
          insGroupData: adjustInfo.updateInsLocPkgList || [],
        },
      });
      if (e.target.value === '1') {
        dispatch({
          type: 'adjusttask/fetchSerConfigList',
        });
      }
    }
  };

  // 选择缴费方式
  selectPayWay = (value, id) => {
    const { form, dispatch, adjustInfo } = this.props;
    dispatch({
      type: 'adjusttask/updateModelData',
      payload: {
        [id]: value.key,
        accountList: [],
      },
    });
    form.resetFields(['accoId', 'bigAccoId', 'grpId']);
    if (value.key === '1' || !(value.key === '2' && adjustInfo.isSupplyRun)) {
      // 获取单立户账户列表
      dispatch({
        type: 'adjusttask/fetchAcountList',
        payload: { payWay: value.key },
      }).then(data => {
        // 单立户：渲染表格数据
        const accoId = form.getFieldValue('accoId');
        let accoName = '';
        if (accoId) {
          data.map(item => {
            if (item.accoId === accoId.key) {
              accoName = item.plcyName;
              return accoName;
            }
          });
        }
        this.setInsGroupData(value.label, accoId ? accoId.label : '', accoId ? accoName : '');
      });
    }
    if (value.key === '2') {
      //  大库:获取社保组合列表
      dispatch({
        type: 'adjusttask/fetchInsGroupList',
      }).then(() => {
        if (adjustInfo.isHasSerAcco && !adjustInfo.isSupplyRun) {
          //  获取工伤二级户
          dispatch({
            type: 'adjusttask/fetchSecAccoList',
            payload: {
              payWay: value.key,
            },
          }).then(secAccuIntValue => {
            form.setFieldsValue({
              injAccoId: secAccuIntValue || undefined,
            });
          });
        }
      });
    }
  };

  // 设置社保组合数据源:缴费方式，账户名称，社保组合，工伤二级户名称
  setInsGroupData = (payWayName, accoName, insGrpName, secAccoName) => {
    const { dispatch, adjustInfo } = this.props;
    const newInsGroupData = JSON.parse(JSON.stringify(adjustInfo.insGroupData));
    newInsGroupData.forEach((item, index) => {
      // adjFlag为true可更改，false为不可更改
      if (item.adjFlag) {
        newInsGroupData[index].payWayName = payWayName;
        newInsGroupData[index].accoName = accoName;
        newInsGroupData[index].insGrpName = insGrpName;
      } else {
        newInsGroupData[index].payWayName = item.payWayName;
        newInsGroupData[index].accoName = item.accoName;
        newInsGroupData[index].insGrpName = item.insGrpName;
      }
    });
    if (secAccoName) {
      // 工伤二级户入口
      newInsGroupData.forEach((item, index) => {
        if (item.adjFlag) {
          if (item.ass === 5) {
            newInsGroupData[index].accoName = secAccoName;
          }
        } else if (item.ass === 5) {
          newInsGroupData[index].accoName = item.accoName;
        }
      });
    }
    dispatch({
      type: 'adjusttask/updateModelData',
      payload: {
        insGroupData: newInsGroupData,
      },
    });
  };

  // 选择服务配置
  selectSerConfig = (value, options) => {
    const { dispatch, adjustInfo, dictCode } = this.props;
    const serConfigInfo = options.props.serconinfo;
    const oldInsGroupData = adjustInfo.insGroupData;
    const newSerConfigInfo = serConfigInfo.map(item => ({ ...item }));
    oldInsGroupData.map(item => {
      const oldItem = { ...item };
      const temp = item;
      temp.payWayName = '';
      temp.accoName = '';
      temp.insGrpName = '';
      newSerConfigInfo.map(s => {
        if (item.ass === s.kind) {
          // 之前版本
          // temp.payWayName = matchDict(
          //   dictCode.PAY_FEES_WAY,
          //   s.payWay
          // );
          // temp.accoName = s.accoName;
          // temp.insGrpName = s.plcyName;

          // 可调整的用新配置的
          if (item.adjFlag) {
            temp.payWayName = matchDict(dictCode.PAY_FEES_WAY, s.payWay);
            temp.accoName = s.accoName;
            temp.insGrpName = s.plcyName;
          } else {
            temp.payWayName = oldItem.payWayName;
            temp.accoName = oldItem.accoName;
            temp.insGrpName = oldItem.insGrpName;
          }
        }
      });
    });
    dispatch({
      type: 'adjusttask/updateModelData',
      payload: {
        insGroupData: oldInsGroupData,
      },
    });
  };

  // 选择大库账户
  selectAccount = (value, options, id) => {
    const { form, dispatch, adjustInfo } = this.props;
    const { secAccoName } = this.state;
    dispatch({
      type: 'adjusttask/updateModelData',
      payload: {
        [id]: (value && value.key) || undefined,
      },
    });
    const plcyInfo = options && options.props && options.props.fsOptions;
    this.setInsGroupData(
      form.getFieldValue('payWay') ? form.getFieldValue('payWay').label : '',
      (value && value.label) || '',
      (plcyInfo && plcyInfo.plcyName) || '',
      adjustInfo.payWay === '2' ? secAccoName : null
    );
    if (adjustInfo.payWay === '2' && !(plcyInfo && plcyInfo.suppPkgs)) {
      // 获取组合所有列表
      dispatch({
        type: 'adjusttask/fetchInsGroupList',
      });
    }
    if (id === 'bigAccoId') {
      // 大库账户
      form.resetFields(['grpId']);
      dispatch({
        type: 'adjusttask/updateModelData',
        payload: {
          grpId: undefined,
        },
      });
      if (plcyInfo && plcyInfo.suppPkgs) {
        // 大库：社保账户带出社保组合
        plcyInfo.suppPkgs.map(item => {
          const obj = item;
          obj.lsPkgId = item.plcyId;
          obj.lsPkgName = item.plcyName;
        });
        dispatch({
          type: 'adjusttask/updateModelData',
          payload: {
            insGroupList: plcyInfo.suppPkgs,
          },
        });
      }
    }
  };

  // 选择社保组合
  selectInsGroup = value => {
    const { form } = this.props;
    const { secAccoName } = this.state;
    this.setInsGroupData(
      form.getFieldValue('payWay') ? form.getFieldValue('payWay').label : '',
      form.getFieldValue('bigAccoId') ? form.getFieldValue('bigAccoId').label : '',
      (value && value.label) || '',
      secAccoName
    );
  };

  // 选择工伤二级户
  selectSecAcco = (value, options) => {
    const { form } = this.props;
    if (value.length === 1) {
      return message.warning(`请选择"${options[0].accoName}"的二级户`);
    }
    let accoName = '';
    options.map((item, index) => {
      accoName += (index > 0 ? '/' : '') + item.label;
    });
    accoName = accoName.trim();
    this.setInsGroupData(
      form.getFieldValue('payWay') ? form.getFieldValue('payWay').label : '',
      form.getFieldValue('bigAccoId') ? form.getFieldValue('bigAccoId').label : '',
      form.getFieldValue('grpId') ? form.getFieldValue('grpId').label : '',
      accoName
    );
    this.setState({ secAccoName: accoName });
  };

  // 提价数据
  submit = () => {
    const { dispatch, form } = this.props;
    const { adjId } = this.state;
    form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        dispatch({
          type: 'adjusttask/submit',
          payload: { adjId, values },
        });
      }
    });
  };

  render() {
    const {
      loading,
      form: { getFieldDecorator },
      adjustInfo: {
        updateBaseInfo,
        updateInsIde, // 缴费人员类别
        insIdeList,
        insIdeFlag,
        updateInsPdDecWage, // 社保申报工资
        insWageFlag,
        updateInsLocPkgList, // 社保组合
        insSetFlag,
        isAssSetFlag,
        insLocFlag,
        insSerConfigFlag,
        serConfigList,
        insPayWayList,
        payWay,
        accountList,
        insGroupList,
        isHasSerAcco,
        secAccoList,
        insGroupData,
        isHasSingle,
        isHasbigStore,
        beginDate,
        isSupplyRun,
      },
    } = this.props;
    const { adjId } = this.state;
    // 判断有无修改
    const isEditInfo = () => {
      let isEdit = false;
      const switchValueList = [insIdeFlag, insWageFlag, insLocFlag];
      isEdit = switchValueList.some(item => item);
      return isEdit;
    };
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 12 },
        md: { span: 10 },
      },
    };
    const insGroupColumns = [
      {
        title: '险种',
        dataIndex: 'assName',
        width: '15%',
        align: 'center',
      },
      {
        title: '缴费方式',
        dataIndex: 'payWayName',
        width: '15%',
        align: 'center',
      },
      {
        title: '缴费账户',
        dataIndex: 'accoName',
        width: '40%',
        align: 'center',
      },
      {
        title: '社保组合',
        dataIndex: 'insGrpName',
        width: '30%',
        align: 'center',
      },
    ];
    return (
      <Form layout="inline">
        <PageHeaderWrapper>
          <Spin tip="Loading..." spinning={loading}>
            <Card>
              {!adjId && (
                <Steps current={1} style={{ marginBottom: 70 }}>
                  <Step title="选择调整项" />
                  <Step title="填写修改信息" />
                  <Step title="完成" />
                </Steps>
              )}
              <Card title={<span style={{ fontWeight: 'bolder' }}>基本信息</span>}>
                <DescriptionList>
                  <Description term="客户名称">{updateBaseInfo.custName || '--'}</Description>
                  <Description term="商务合同">{updateBaseInfo.custContName || '--'}</Description>
                  <Description term="报价单">{updateBaseInfo.quoName || '--'}</Description>
                  <Description term="姓名">{updateBaseInfo.empName || '--'}</Description>
                  <Description term="证件类型">{updateBaseInfo.idTypeName || '--'}</Description>
                  <Description term="证件号">{updateBaseInfo.idCode || '--'}</Description>
                </DescriptionList>
              </Card>
              <Card title={<span style={{ fontWeight: 'bolder' }}>社保申报信息</span>}>
                <div className={styles.addempUpdateStyle1}>
                  {updateInsIde && (
                    <div>
                      <Row className={styles.addempUpdateStyle}>
                        <Col offset={2}>
                          <FormItem
                            label={
                              <span style={{ display: 'inline-block', width: 108 }}>
                                缴费人员类别
                              </span>
                            }
                            colon={false}
                            style={{ marginLeft: 30 }}
                          >
                            {getFieldDecorator('insIdeFlag', {
                              valuePropName: 'checked',
                              rules: [{ required: false, message: '请选择' }],
                              initialValue: insIdeFlag,
                            })(
                              <Switch
                                checkedChildren="修改"
                                unCheckedChildren="不修改"
                                style={{ width: 70 }}
                                onChange={check => this.changeSWitch(check, 'insIdeFlag')}
                              />
                            )}
                          </FormItem>
                          <FormItem
                            label="缴费人员类别"
                            style={{ width: '100%', marginLeft: 150 }}
                            {...formItemLayout}
                            className={styles.addempRemark}
                          >
                            {getFieldDecorator('updateInsIde.insIde', {
                              rules: [{ required: insIdeFlag, message: '请选择' }],
                              initialValue: updateInsIde.oldInsIde || undefined,
                            })(
                              insIdeFlag ? (
                                <HOCSelect
                                  placeholder="请选择"
                                  showSearch
                                  optionFilterProp="children"
                                >
                                  {insIdeList.map(item => (
                                    <Option key={item.ideId} value={item.ideId}>
                                      {item.ideName}
                                    </Option>
                                  ))}
                                </HOCSelect>
                              ) : (
                                <span>{updateInsIde.oldInsIdeName}</span>
                              )
                            )}
                          </FormItem>
                        </Col>
                      </Row>
                      <Divider dashed style={{ marginBottom: 14 }} />
                    </div>
                  )}
                  {updateInsPdDecWage && (
                    <div>
                      <Row className={styles.addempUpdateStyle}>
                        <Col offset={2}>
                          <FormItem
                            label={
                              <span style={{ display: 'inline-block', width: 108 }}>
                                社保申报工资
                              </span>
                            }
                            colon={false}
                            style={{ marginLeft: 30, marginBottom: 10 }}
                          >
                            {getFieldDecorator('insWageFlag', {
                              valuePropName: 'checked',
                              rules: [{ required: false, message: '请选择' }],
                              initialValue: insWageFlag,
                            })(
                              <Switch
                                checkedChildren="修改"
                                unCheckedChildren="不修改"
                                style={{ width: 70 }}
                                onChange={check => this.changeSWitch(check, 'insWageFlag')}
                              />
                            )}
                          </FormItem>
                          {insWageFlag ? (
                            insSetFlag === 1 ? (
                              <FormItem
                                label="社保申报工资"
                                style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                                {...formItemLayout}
                              >
                                {getFieldDecorator('updateInsPdDecWage.insDecWage', {
                                  rules: [
                                    {
                                      required: true,
                                      // message: '请输入小数点不超过2位的数字',
                                      // pattern: /^-?\d+\.?\d{0,2}$/,
                                      message: '请输入整数',
                                      pattern: /^[1-9]\d*$/,
                                    },
                                  ],
                                  initialValue: updateInsPdDecWage.oldInsDecWage,
                                })(
                                  // <InputNumber
                                  //   min={0}
                                  //   max={9999999.99}
                                  //   placeholder="请输入"
                                  //   style={{ width: 600 }}
                                  // />
                                  <InputNumber
                                    min={0}
                                    max={9999999}
                                    placeholder="请输入"
                                    style={{ width: 600 }}
                                  />
                                )}
                              </FormItem>
                            ) : (
                              <div>
                                <FormItem
                                  label="分项险种设置"
                                  style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                                  {...formItemLayout}
                                >
                                  {getFieldDecorator('isAssSetFlag', {
                                    rules: [{ required: true, message: '请选择' }],
                                    initialValue: isAssSetFlag,
                                  })(
                                    updateInsPdDecWage.assSetFlag ? (
                                      <DictCode
                                        dictType="YES_NO_FLAG"
                                        inputType="3"
                                        onChange={e => this.changeRadio(e, 'isAssSetFlag')}
                                      />
                                    ) : (
                                      <Radio.Group
                                        onChange={e => this.changeRadio(e, 'isAssSetFlag')}
                                      >
                                        <Radio value="1">是</Radio>
                                      </Radio.Group>
                                    )
                                  )}
                                </FormItem>
                                {isAssSetFlag === '1' ? (
                                  updateInsPdDecWage.updateInsDecWageList.map(item => (
                                    <FormItem
                                      key={item.ass}
                                      label={`${item.assName}申报工资`}
                                      style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                                      {...formItemLayout}
                                    >
                                      {getFieldDecorator(
                                        `updateInsPdDecWage.updateInsDecWageList.wage_${item.ass}`,
                                        {
                                          rules: [
                                            {
                                              required: true,
                                              // message: '请输入小数点不超过2位的数字',
                                              // pattern: /^-?\d+\.?\d{0,2}$/,
                                              message: '请输入整数',
                                          pattern: /^[1-9]\d*$/,
                                            },
                                          ],
                                          initialValue: item.oldInsDecWage,
                                        }
                                      )(
                                        // <InputNumber
                                        //   min={0}
                                        //   max={9999999.99}
                                        //   placeholder="请输入"
                                        //   style={{ width: 600 }}
                                        //   disabled={!item.adjFlag}
                                        // />
                                        <InputNumber
                                          min={0}
                                          max={9999999}
                                          placeholder="请输入"
                                          style={{ width: 600 }}
                                          disabled={!item.adjFlag}
                                        />
                                      )}
                                    </FormItem>
                                  ))
                                ) : (
                                  <FormItem
                                    label="社保申报工资"
                                    style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                                    {...formItemLayout}
                                  >
                                    {getFieldDecorator('updateInsPdDecWage.insDecWage', {
                                      rules: [
                                        {
                                          required: true,
                                          // message: '请输入小数点不超过2位的数字',
                                          // pattern: /^-?\d+\.?\d{0,2}$/,
                                          message: '请输入整数',
                                          pattern: /^[1-9]\d*$/,
                                        },
                                      ],
                                      initialValue: updateInsPdDecWage.oldInsDecWage,
                                    })(
                                      // <InputNumber
                                      //   min={0}
                                      //   max={9999999.99}
                                      //   placeholder="请输入"
                                      //   style={{ width: 600 }}
                                      // />
                                      <InputNumber
                                        min={0}
                                        max={9999999}
                                        placeholder="请输入"
                                        style={{ width: 600 }}
                                      />
                                    )}
                                  </FormItem>
                                )}
                              </div>
                            )
                          ) : insSetFlag === 1 ? (
                            <FormItem
                              label="社保申报工资"
                              style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                              {...formItemLayout}
                            >
                              {getFieldDecorator('updateInsPdDecWage.insDecWage', {
                                rules: [
                                  {
                                    required: true,
                                    // message: '请输入小数点不超过2位的数字',
                                    // pattern: /^-?\d+\.?\d{0,2}$/,
                                    message: '请输入整数',
                                    pattern: /^[1-9]\d*$/,
                                  },
                                ],
                                initialValue: updateInsPdDecWage.oldInsDecWage,
                              })(
                                <span>
                                  {updateInsPdDecWage.oldInsDecWage &&
                                    updateInsPdDecWage.oldInsDecWage.toFixed(2)}
                                </span>
                              )}
                            </FormItem>
                          ) : (
                            updateInsPdDecWage.updateInsDecWageList.map(item => (
                              <FormItem
                                key={item.ass}
                                label={`${item.assName}申报工资`}
                                style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                                {...formItemLayout}
                              >
                                {getFieldDecorator(
                                  `updateInsPdDecWage.updateInsDecWageList.wage_${item.ass}`,
                                  {
                                    rules: [
                                      {
                                        required: false,
                                        // message: '请输入小数点不超过2位的数字',
                                        // pattern: /^-?\d+\.?\d{0,2}$/,
                                        message: '请输入整数',
                                          pattern: /^[1-9]\d*$/,
                                      },
                                    ],
                                  }
                                )(
                                  <span>{item.oldInsDecWage && item.oldInsDecWage.toFixed(2)}</span>
                                )}
                              </FormItem>
                            ))
                          )}
                        </Col>
                      </Row>
                    </div>
                  )}
                  {updateInsLocPkgList && (
                    <div>
                      <Divider dashed style={{ marginBottom: 14 }} />
                      <Row className={styles.addempUpdateStyle}>
                        <Col offset={2}>
                          <FormItem
                            label={
                              <span style={{ display: 'inline-block', width: 108 }}>社保组合</span>
                            }
                            colon={false}
                            style={{ marginLeft: 30, marginBottom: 10 }}
                          >
                            {getFieldDecorator('insLocFlag', {
                              valuePropName: 'checked',
                              rules: [{ required: false, message: '请选择' }],
                              initialValue: insLocFlag,
                            })(
                              <Switch
                                checkedChildren="修改"
                                unCheckedChildren="不修改"
                                style={{ width: 70 }}
                                onChange={check => this.changeSWitch(check, 'insLocFlag')}
                              />
                            )}
                          </FormItem>
                          {insLocFlag && (
                            <div>
                              <FormItem
                                label="服务配置"
                                style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                                {...formItemLayout}
                              >
                                {getFieldDecorator('insSerConfigFlag', {
                                  rules: [{ required: true, message: '请选择' }],
                                  initialValue: insSerConfigFlag,
                                })(
                                  <DictCode
                                    dictType="YES_NO_FLAG"
                                    inputType="3"
                                    onChange={e => this.changeRadio(e, 'insSerConfigFlag')}
                                  />
                                )}
                              </FormItem>
                              {insSerConfigFlag === '1' && (
                                <FormItem
                                  label="使用服务配置"
                                  style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                                  {...formItemLayout}
                                >
                                  {getFieldDecorator('serSetId', {
                                    rules: [{ required: true, message: '请选择' }],
                                  })(
                                    <HOCSelect
                                      placeholder="请选择"
                                      labelInValue
                                      showSearch
                                      optionFilterProp="children"
                                      style={{ width: 600 }}
                                      onSelect={(value, options) =>
                                        this.selectSerConfig(value, options)
                                      }
                                    >
                                      {serConfigList.map(item => (
                                        <Option key={item.custConfId} serconinfo={item.confDetList}>
                                          {item.custConfNo}
                                        </Option>
                                      ))}
                                    </HOCSelect>
                                  )}
                                </FormItem>
                              )}
                              {insSerConfigFlag === '2' && (
                                <div>
                                  <FormItem
                                    label="缴费方式"
                                    style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                                    {...formItemLayout}
                                  >
                                    {getFieldDecorator('payWay', {
                                      rules: [{ required: true, message: '请选择' }],
                                    })(
                                      <HOCSelect
                                        placeholder="请选择"
                                        labelInValue
                                        showSearch
                                        optionFilterProp="children"
                                        style={{ width: 600 }}
                                        onSelect={value => this.selectPayWay(value, 'payWay')}
                                      >
                                        {insPayWayList.map(options => (
                                          <Option key={options.itemCode}>{options.itemName}</Option>
                                        ))}
                                      </HOCSelect>
                                    )}
                                  </FormItem>
                                  {isHasSingle && (payWay == null || payWay === '1') ? (
                                    <FormItem
                                      label="单立户账户"
                                      style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                                      {...formItemLayout}
                                    >
                                      {getFieldDecorator('accoId', {
                                        rules: [{ required: true, message: '请选择' }],
                                      })(
                                        <HOCSelect
                                          placeholder="请选择"
                                          labelInValue
                                          showSearch
                                          optionFilterProp="children"
                                          style={{ width: 600 }}
                                          onChange={(value, options) =>
                                            this.selectAccount(value, options, 'accoId')
                                          }
                                        >
                                          {accountList.map(options => (
                                            <Option
                                              key={options.accoId}
                                              value={options.accoId}
                                              // options={options}
                                              fsOptions={options}
                                            >
                                              {options.accoName}
                                            </Option>
                                          ))}
                                        </HOCSelect>
                                      )}
                                    </FormItem>
                                  ) : (
                                    isHasbigStore &&
                                    payWay === '2' && (
                                      <div>
                                        {!(isSupplyRun && payWay === '2') && (
                                          <FormItem
                                            label="大库账户"
                                            style={{
                                              width: '100%',
                                              marginBottom: 10,
                                              marginLeft: 150,
                                            }}
                                            {...formItemLayout}
                                          >
                                            {getFieldDecorator('bigAccoId', {
                                              rules: [{ required: false, message: '请选择' }],
                                            })(
                                              <HOCSelect
                                                placeholder="请选择"
                                                labelInValue
                                                showSearch
                                                allowClear
                                                optionFilterProp="children"
                                                style={{ width: 600 }}
                                                onChange={(value, options) =>
                                                  this.selectAccount(value, options, 'bigAccoId')
                                                }
                                              >
                                                {accountList.map(options => (
                                                  <Option
                                                    key={options.accoId}
                                                    value={options.accoId}
                                                    // options={options}
                                                    fsOptions={options}
                                                  >
                                                    {options.accoName}
                                                  </Option>
                                                ))}
                                              </HOCSelect>
                                            )}
                                          </FormItem>
                                        )}
                                        <FormItem
                                          label="社保组合"
                                          style={{
                                            width: '100%',
                                            marginBottom: 10,
                                            marginLeft: 150,
                                          }}
                                          {...formItemLayout}
                                        >
                                          {getFieldDecorator('grpId', {
                                            rules: [{ required: true, message: '请选择' }],
                                          })(
                                            <HOCSelect
                                              placeholder="请选择"
                                              labelInValue
                                              showSearch
                                              optionFilterProp="children"
                                              style={{ width: 600 }}
                                              onChange={this.selectInsGroup}
                                            >
                                              {insGroupList.map(item => (
                                                <Option
                                                  key={item.lsPkgId}
                                                  value={item.lsPkgId}
                                                  // options={item}
                                                  fsOptions={item}
                                                >
                                                  {item.lsPkgName}
                                                </Option>
                                              ))}
                                            </HOCSelect>
                                          )}
                                        </FormItem>
                                      </div>
                                    )
                                  )}
                                  {updateBaseInfo.cityId === '1415662' &&
                                    payWay === '2' &&
                                    !isSupplyRun &&
                                    isHasSerAcco && (
                                      <FormItem
                                        label="工伤二级户"
                                        style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                                        {...formItemLayout}
                                      >
                                        {getFieldDecorator('injAccoId', {
                                          rules: [{ required: true, message: '请选择' }],
                                        })(
                                          <Cascader
                                            placeholder="请输入关键字检索"
                                            options={secAccoList}
                                            showSearch
                                            notFoundContent="暂无工伤二级户"
                                            onChange={(value, selectedOptions) =>
                                              this.selectSecAcco(value, selectedOptions)
                                            }
                                            changeOnSelect
                                            style={{ width: 600 }}
                                          />
                                        )}
                                      </FormItem>
                                    )}
                                </div>
                              )}
                            </div>
                          )}
                          {insLocFlag ? (
                            <FormItem
                              label="&nbsp;"
                              style={{ width: '100%', marginBottom: 10, marginLeft: 150 }}
                              colon={false}
                              {...formItemLayout}
                            >
                              {getFieldDecorator('insGroupTable', {
                                rules: [{ required: false, message: '请选择' }],
                              })(
                                <Table
                                  style={{ width: 600 }}
                                  columns={insGroupColumns}
                                  dataSource={insGroupData}
                                  rowKey="ass"
                                  bordered
                                  size="middle"
                                  pagination={false}
                                  rowClassName={record =>
                                    record.adjFlag === true ? '' : styles.rowSelectionDisabled
                                  }
                                />
                              )}
                            </FormItem>
                          ) : (
                            <Table
                              style={{ width: 800, marginLeft: 150 }}
                              columns={insGroupColumns}
                              dataSource={insGroupData}
                              rowKey="ass"
                              bordered
                              size="middle"
                              pagination={false}
                              rowClassName={record =>
                                record.adjFlag === true ? '' : styles.rowSelectionDisabled
                              }
                            />
                          )}
                          {isEditInfo() && (
                            <FormItem
                              label="生效日期"
                              style={{ width: '100%', marginTop: 30, marginLeft: 150 }}
                              {...formItemLayout}
                            >
                              {getFieldDecorator('beginDate', {
                                rules: [{ required: true, message: '请选择' }],
                                initialValue: (beginDate && moment(beginDate)) || undefined,
                              })(
                                <MonthPicker
                                  placeholder="请选择"
                                  allowClear={false}
                                  style={{ width: 600 }}
                                  format="YYYY-MM-01"
                                />
                              )}
                              <p style={{ color: '#a4a4a4', width: 600 }}>
                                注：缴费人员类别、社保/公积金组合不可调整历史生效年月。
                              </p>
                            </FormItem>
                          )}
                        </Col>
                      </Row>
                    </div>
                  )}
                </div>
              </Card>
              <div style={{ marginTop: '100px', marginBottom: '30px', textAlign: 'center' }}>
                <Button style={{ marginRight: '30px' }} onClick={() => router.goBack()}>
                  返回
                </Button>
                <Button type="primary" onClick={this.submit} disabled={!isEditInfo()}>
                  提交
                </Button>
              </div>
            </Card>
          </Spin>
        </PageHeaderWrapper>
      </Form>
    );
  }
}

const BasicFormList = Form.create()(BasicForm);
export default BasicFormList;
